package com.story.api.moduler.option.service.impl;

import com.story.api.common.persistence.dao.FeedbackMapper;
import com.story.api.common.persistence.model.Feedback;
import com.story.api.common.result.ServerResponse;
import com.story.api.moduler.option.dto.FeedbackDto;
import com.story.api.moduler.option.service.FeedbackService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author Administrator
 * @decription 反馈意见提交
 * @Date 2017-12-15 11:28
 */
@Service
public class FeedbackServiceImpl implements FeedbackService {

    private static final Logger log = LoggerFactory.getLogger(FeedbackServiceImpl.class);

    @Autowired
    private FeedbackMapper feedbackMapper;

    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public ServerResponse submitFeedback(FeedbackDto feedbackDto) {
        Feedback feedback = new Feedback();
        feedback.setQqNumber(feedbackDto.getQqNumber());
        feedback.setOptionContent(feedbackDto.getContent());
        feedback.setStatus(false);
        feedback.setCreateTime(new Date());
        feedbackMapper.insert(feedback);
        log.info("意见提交成功");
        return ServerResponse.getSuccess("反馈意见提交成功");
    }
}
